package org.dormi.learn.utils;

import java.util.Objects;

/**
 * add description here
 *
 * @author : dormi330
 * @version : 1.0
 */
public final class Assert {

    /* This class is not intended to be instantiated. */
    private Assert() {
        // not allowed
    }

//    @Deprecated
//    public static void notNull(Object obj) {
//        Objects.requireNonNull(obj);
//    }

//    @Deprecated
//    public static void notNull(Object obj, String msg) {
//        Objects.requireNonNull(msg);
//    }

//    public static void isEquals(Object o1, Object o2) {
//        if (!Objects.equals(o1, o2)) {
//            throw new RuntimeException("Not equal");
//        }
//    }

//    public static boolean isLegal(boolean expression) {
//        return isLegal(expression, ""); //$NON-NLS-1$
//    }

    public static boolean isLegal(boolean expression, String message) {
        if (!expression)
            throw new IllegalArgumentException(message);
        return expression;
    }

//    public static void isNotNull(Object object) {
//        isNotNull(object, ""); //$NON-NLS-1$
//    }

    public static void isNotNull(Object object, String msg) {
        if (object == null)
            // throw new RuntimeException("null argument:" + message); //$NON-NLS-1$
            throw new RuntimeException(msg); //$NON-NLS-1$
    }


//    public static boolean isTrue(boolean expression) {
//        return isTrue(expression, ""); //$NON-NLS-1$
//    }

    public static boolean isTrue(boolean expression, String message) {
        if (!expression)
            throw new RuntimeException("assertion failed: " + message); //$NON-NLS-1$
        return expression;
    }
}
